//��pwd��path�ϲ�������.������������..��ɾ����һ��Ŀ¼
#include<iostream>
#include<sstream>
#include<vector>
#include<string>
using namespace std;
string Simple_combine(string& path,string& pwd)
{
    string combine_path = path+"/"+pwd;
    istringstream iss(combine_path);
    vector<string> parts;
    string part;
    
    while(getline(iss,part,'/'))
    {
        if(part.empty()||part==".") continue;
        else if(part=="..")
        {
            if(!parts.empty())
            {
                parts.pop_back();
            }
        }
        else
        {
            parts.push_back(part);
        }
    }

    ostringstream oss;
    for(const auto& segment: parts)
    {
        if(!oss.str().empty())
        {
            oss<<"/";
        }
        oss<<segment;
    }

    if(oss.str().empty())
    {
        oss<<".";
    }
    return oss.str();
}

int main()
{
    std::string pwd = "/home/user";
    std::string path = "dir1/..//dir2/./dir3";
    std::string result = Simple_combine(pwd, path);
    std::cout << "Simplified Path: " << result << std::endl;
    return 0;
}